
export class GeoData {
    public name: string;
    public id: string;
    public description: string;
    public optional: number;
    constructor(
        name: string,
        description?: string,
        optional?: number,
        id?: string,
    ) {
        this.name = name;

        if (id) {
            this.id = id;
        }
        if (description) {
            this.description = description;
        }
        if (optional) {
            this.optional = optional
        } else {
            this.optional = 0;
        }
    }
}

export class ToolIOData {
    public stateId: string;
    public stateName: string;
    public stateDesc: string;
    public input: Array<GeoData>;
    public output: Array<GeoData>;
    constructor(
        stateId: string,
        stateName: string,
        stateDesc: string,
        input: Array<GeoData>,
        output: Array<GeoData>
    ) {
        this.input = input;
        this.output = output;
        this.stateId = stateId;
        this.stateName = stateName;
        this.stateDesc = stateDesc
    }
}

export class postData {
    public stateid: string;
    public statename: string;
    public statedesc: string;
    public eventname: string;
    public myfile: File;

    constructor(stateid: string,
        statename: string,
        statedesc: string,
        eventname: string,
        myfile: File) {
        this.stateid = stateid;
        this.statename = statename;
        this.statedesc = statedesc
        this.eventname = eventname;
        this.myfile = myfile;
    }
}

export class uploadResponseData {
    public StateId: string;
    public StateName: string;
    public StateDesc: string;
    public Event: string;
    public ResponseData: any;
    constructor(StateId: string,
        StateName: string,
        StateDesc: string,
        EventName: string,
        ResponseData: any
    ) {
        this.StateId = StateId;
        this.StateName = StateName,
            this.StateDesc = StateDesc,
            this.Event = EventName;
        this.ResponseData = ResponseData;
    }
}
// /modelser/:msid?ac=run&inputdata=[{"StateId":":sid","Event":":eventname","DataId":":gdid"},{"StateId":":sid","Event":":eventname","DataId":":gdid"}]
export class DataForRunModel {
    public StateId: string;
    public StateName: string;
    public StateDes: string;
    public Event: string;
    public DataId: string;
    constructor(
        StateId: string,
        StateName: string,
        StateDes: string,
        event: string,
        DataId: string
    ) {
        this.StateId = StateId;
        this.StateName = StateName;
        this.StateDes = StateDes;
        this.Event = event;
        this.DataId = DataId;
    }
}


////layer

export class LayerItem {
    public name: string;
    public dataId: string;
    public visible: boolean;
    public file: File;
    public isLocal: boolean;
    public uploaded: boolean;
    public layerShowing: boolean;
    constructor(
        name: string,
        isLocal?: boolean,
        file?: File,
        dataId?: string,
        visible?: boolean,
    ) {
        this.name = name;
        if (isLocal) {
            this.isLocal = isLocal;
        }
        if (this.isLocal) {
            this.dataId = this.NewGuid();
        } else {
            this.dataId = dataId;
        }
        if (file) {
            this.file = file;
        }
        if (visible !== undefined) {
            this.visible = visible;
        } else {
            this.visible = false;
        }
        this.uploaded = false;
        this.layerShowing = false;
    }


    private S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    }
    private NewGuid() {
        return (this.S4() + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + this.S4() + this.S4());
    }

}


export class GeoJsonLayer {
    public id: string;
    public data: string;

    constructor(id: string, data: string) {
        this.id = id;
        this.data = data;
    }

}

////Tree

export class ToolsTreeNode {
    public id: string = null;
    public modelId: string = null;
    public parentId: string = null;
    public value: string = null;
    public children: Array<ToolsTreeNode> = null;
    constructor(id?: string,
        modelId?: string,
        value?: string,
        parentId?: string,
        children?: Array<ToolsTreeNode>) {

        if (id) this.id = id;
        if (modelId) this.modelId = modelId;
        if (parentId) this.parentId = parentId;
        if (value) this.value = value;
        if (children) this.children = children;

    }

    public setTreeNode(treeNode: {
        id?: string,
        modelId?: string,
        value?: string,
        parentId?: string,
        children?: Array<ToolsTreeNode>
    }) {
        if (treeNode.id) this.id = treeNode.id;
        if (treeNode.modelId) this.modelId = treeNode.modelId;
        if (treeNode.parentId) this.parentId = treeNode.parentId;
        if (treeNode.value) this.value = treeNode.value;
        if (treeNode.children) this.children = treeNode.children;
    }


}

////mouse click event

export class XYDistance {
    public DistanceX: number;
    public DistanceY: number;
    constructor(DistanceX: number,
        DistanceY: number) {
        this.DistanceX = DistanceX;
        this.DistanceY = DistanceY;
    }
    setXYDistance(DistanceX: number,
        DistanceY: number) {
        this.DistanceX = DistanceX;
        this.DistanceY = DistanceY;
    }
}